﻿package dut.ir.lxb.weibo.util;

import java.io.IOException;
import java.io.StringReader;

import net.paoding.analysis.analyzer.PaodingAnalyzer;

import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.tokenattributes.TermAttribute;

public class TermSpiliter
{
	@SuppressWarnings("resource")
	public static String spilitWords(String str)
	{

		PaodingAnalyzer analyzer = new PaodingAnalyzer();
		analyzer.setMode(PaodingAnalyzer.MOST_WORDS_MODE);
		TokenStream tokenStream = analyzer.tokenStream(str, new StringReader(str));
		String returnValue = "";
		try
		{
			// System.out.println(docText);
			while (tokenStream.incrementToken())
			{
				TermAttribute t = tokenStream.getAttribute(TermAttribute.class);
				returnValue = returnValue + " " + t.term();
			}
		} 
		catch (IOException e)
		{
			e.printStackTrace();
		}
		return returnValue;
		
	}
	
}
